<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-house__houseseal}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
         <el-row>
          <el-col :span="19">
            <el-form-item>
              申请日期：
              <el-date-picker
                v-model="dataForm.createDates"
                type="date"
                placeholder="开始时间"
                value-format="yyyy-MM-dd"
                style="width:136px"
              ></el-date-picker>
              {{' -'}}
              <el-date-picker
                v-model="dataForm.createDatee"
                type="date"
                placeholder="结束时间"
                value-format="yyyy-MM-dd"
                style="width:136px"
              ></el-date-picker>
            </el-form-item>

            <el-form-item>
              部门：
              <el-cascader
                class="FormSelect"
                v-model="deptSelectVal"
                :options="this.$store.state.DeptList"
                :show-all-levels="false"
                @change="deptIdChange"
                :props="deptProps"
                ref="myCascader"
                clearable
              ></el-cascader>-
              <el-select v-model="dataForm.userId" placeholder="人员" class="FormSelect" clearable>
                <el-option
                  v-for="item in maintainList"
                  :key="item.id"
                  :label="item.realName"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>


            <el-form-item>
              审核：
              <ren-select
                v-model="dataForm.examine"
                dict-type="examine"
                placeholder="审核类型"
                class="FormSelect"
              ></ren-select>
            </el-form-item>
            <el-form-item>
              <el-button
               v-if="$hasPermission('house:houseseal:delete')"
                type="danger"
                @click="deleteHandle()"
              >删除</el-button>
            </el-form-item>

          </el-col>

          <el-col :span="5">
            搜索：
            <el-input
              placeholder="请输入内容"
              v-model="dataForm.search"
              class="input-with-select"
              @keyup.enter.native="getDataList"
              clearable
              style="width:70%"
            >
              <el-button slot="append" icon="el-icon-search" @click="getDataList"></el-button>
            </el-input>
          </el-col>
        </el-row>

      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
      
        <el-table-column prop="houseId" label="房源编号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="content" label="封盘原因" header-align="center" align="center"></el-table-column>
        <el-table-column prop="endTime" label="结束时间" header-align="center" align="center"></el-table-column>
        
        <el-table-column prop="deptId" label="申请部门" header-align="center" align="center"></el-table-column>
        <el-table-column prop="creator" label="申请人" header-align="center" align="center"></el-table-column>
        <el-table-column prop="createDate" label="申请时间" header-align="center" align="center"></el-table-column>
        <el-table-column prop="examine" label="封盘审核" header-align="center" align="center"></el-table-column>
<!--         
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('house:houseseal:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
            <el-button v-if="$hasPermission('house:houseseal:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
          </template>
        </el-table-column> -->
      </el-table>
     <div class="paginationBox">
        <el-pagination
          :current-page="page"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="limit"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="pageSizeChangeHandle"
          @current-change="pageCurrentChangeHandle"
        ></el-pagination>
      </div>
      <!-- 弹窗, 新增 / 修改 -->
      <!-- <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update> -->
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/house/houseseal/page',
        getDataListIsPage: true,
        exportURL: '/house/houseseal/export',
        deleteURL: '/house/houseseal',
        deleteIsBatch: true
      },
      dataForm: {
        id: "",
        examine: "", //审核状态
        createDates: "",
        createDatee: "",
        deptId: "", //部门
        userId: "",
        search: "",
  
      },
      deptSelectVal: "",
      deptProps: {
        value: "id",
        label: "name",
        checkStrictly: true
      },
      maintainList: this.$store.state.maintainList
    }
  },
  components: {
   
  },
   methods: {
    //审核
    tabExamineChange(row) {
      this.$http
        .put(
          `/contract/contractimage/updateExamine`,
          {},
          {
            params: {
              id: row.id,
              examine: row.examine
            }
          }
        )
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          }
          this.$message.success("更改成功");
        })
        .catch(() => {});
    },
    //一键审核
    updateExamineList() {
      let _this = this;
      let arr = [];
      for (let i = 0; i < _this.dataListSelections.length; i++) {
        const element = _this.dataListSelections[i];
        arr.push(element.id);
      }
      this.$http
        .post(
          "/contract/contractimage/updateExamineList",
          {},
          {
            params: {
              ids: arr.join()
            }
          }
        )
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          }
          this.$message.success("审核成功");
          this.getDataList();
        })
        .catch(() => {});
    },
    deptIdChange(val) {
      let a = "";
      if (this.$refs.myCascader.getCheckedNodes()[0]) {
        a = this.$refs.myCascader.getCheckedNodes()[0].value;
        this.dataForm.deptId = a;
        this.getUserList(a);
      } else {
        this.dataForm.deptId = "";
      }
    },
    // 获取部门员工列表
    getUserList(deptId) {
      let _this = this;
      this.$http
        .get(`/sys/user/deptUserList`, {
          params: {
            deptId: deptId
          }
        })
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          }
          _this.maintainList = res.data;
        })
        .catch(() => {});
    },
  },
   watch: {
    dataForm: {
      handler(nowVal, oldVal) {
        this.getDataList();
      },
      deep: true
    }
  }
}
</script>
